<?php
if (!$listid)
{
	$to = 'index.php?cmd=login';
	header('Location: '. $to);
}
?>

<?php
	$color01 = "4d4e66";
	$color02 = "#d8d8f0";
	$color03 = "#cccccc";
	$orderby = $_GET['orderby'];
	if (!$orderby)
	{
		$orderby = "Fullname";
	}

	mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
	@mysql_select_db("$DBName") or die("Unable to select database $DBName");
	$sqlquery = "select * from $TReceivers where ListId = '$listid' order by $orderby";
	$results = mysql_query($sqlquery) or die("Unable to query : " . mysql_error());

	// Printer resultatet i HTML
	echo "<table width='960'>\n";
	echo "\t<tr bgcolor='$color01' style='color:#ffffff; font-weight:bold;'>\n";
	echo "\t\t<td></td>\n";
	echo "\t\t<td>Navn</td>\n";
	echo "\t\t<td>Fornavn</td>\n";
	echo "\t\t<td>Mobil</td>\n";
	echo "\t\t<td>Telefon</td>\n";
	echo "\t\t<td>Email</td>\n";
	echo "\t\t<td>Fødselsdag</td>\n";
	echo "\t\t<td></td>\n";
	echo "\t\t<td></td>\n";
        echo "\t</tr>\n";

	while ($line = mysql_fetch_array($results, MYSQL_ASSOC))
	{
   		if ($color == $color03)
		{
			$color = $color02;
		}
		else
		{
			$color = $color03;
		}
		echo "\t<tr bgcolor='$color'>\n";

		$receiverid = $line["ReceiverId"];
		//$listid		= $line["ListId"];
		$fullname	= $line["FullName"];
                //$fullname	= utf8_decode($fullname);
		$shortname	= $line["ShortName"];
                //$shortname	= utf8_decode($shortname);
		$cellphone	= $line["CellPhone"];
		$phone		= $line["Phone"];
		$email		= $line["Email"];
		$birthday	= $line["BirthDay"];

		if ($birthday == "0000-00-00")
		{
			$birthday = "";
		}
		if ($phone == "0")
		{
			$phone = "";
		}
		if ($cellphone == "0")
		{
			$cellphone = "";
		}

		echo "\t\t<td style='text-align: center;'><a href='../../index.php?cmd=sms2oneform&receiverid=$receiverid&listid=$listid&phone=$fromphone' class='list'>sms til:</a></td>\n";
		echo "\t\t<td>$fullname</td>\n";
       	echo "\t\t<td>$shortname</td>\n";
		echo "\t\t<td>$cellphone</td>\n";
		echo "\t\t<td>$phone</td>\n";
		echo "\t\t<td>$email</td>\n";
		echo "\t\t<td>$birthday</td>\n";
		echo "\t\t<td style='text-align: center;'><a href='../../index.php?cmd=receiverformupdate&receiverid=$receiverid&listid=$listid&phone=$fromphone' class='list'>Opdater</a></td>\n";
		echo "\t\t<td style='text-align: center;'><a href='../../receiverdelete.php?receiverid=$receiverid&listid=$listid&phone=$fromphone' class='list'>Slet</a></td>\n\t</tr>\n";
	}
	echo "</table>\n";

	mysql_free_result($results);
	mysql_close();

?>